//
//  OptimizationBaseViewListViewController.m
//  AnXin100
//
//  Created by Sakura on 2018/11/14.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "OptimizationBaseViewListViewController.h"
#import "XXPageTabView.h"
#import "XXPageTabItemLable.h"
#import "BaseShowViewController.h"
@interface OptimizationBaseViewListViewController ()<XXPageTabViewDelegate>
@property (nonatomic, strong) XXPageTabView *pageTabView;

@end

@implementation OptimizationBaseViewListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.pageTabView];
}

- (XXPageTabView *)pageTabView
{
    if (!_pageTabView) {
        
        for (NSInteger i = 0; i < 4; i++) {
            BaseShowViewController *vc = [BaseShowViewController new];
            vc.isHeight = YES;
            [self addChildViewController:vc];
        }
        
        //支持网易云音乐，今日头条，微博等切换栏效果
        _pageTabView = [[XXPageTabView alloc] initWithChildControllers:self.childViewControllers childTitles:@[@"绿色产品", @"有机产品",@"种植技术",@"特色农产品"]];
        _pageTabView.frame = CGRectMake(0, Hn, Wi, Hi-Hn);
        
        _pageTabView.selectedTabIndex = 0;
        _pageTabView.maxNumberOfPageItems = 5;
        _pageTabView.tabSize = CGSizeMake(Wi, 44);
        _pageTabView.tabItemFont = FONT_FOURTEEN;
        
        _pageTabView.unSelectedColor = White(50);
        _pageTabView.selectedColor = COLOR_GREEN;
        
        _pageTabView.tabBackgroundColor = White(250);
        
        _pageTabView.separatorColor = [[UIColor grayColor] colorWithAlphaComponent:0.4];
        _pageTabView.bodyBounces = NO;
        
        _pageTabView.indicatorWidth = 50;
        _pageTabView.indicatorHeight = 2;
        
        _pageTabView.delegate = self;
        _pageTabView.titleStyle = XXPageTabTitleStyleDefault;
        _pageTabView.indicatorStyle = XXPageTabIndicatorStyleDefault;
        
        UIScrollView *bodyView = [_pageTabView valueForKey:@"bodyView"];
        [bodyView.panGestureRecognizer requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];
    }
    return _pageTabView;
}

- (void)pageTabViewDidEndChange
{
    DLog(@"page = %i", (int)self.pageTabView.selectedTabIndex);
}

@end
